{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "!mkdir -p /mnt/data/mydataset/train_img\n",
    "!mkdir -p /mnt/data/mydataset/aligned_img\n",
    "!mkdir -p /mnt/data/mydataset/test_img\n",
    "!mkdir -p /mnt/data/mydataset/test_aligned_img\n",
    "#data mv tock  样本人 tock\n",
    "#data mv trevor 样本人脸 trevor\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Preprocess the raw images  \n",
    "jupyter 对shell的多线线程的支持程度不明确，若要使用多线程需要进入容器shell执行\n",
    "这里对图片做归一化处理，框选出人脸部分，调整到统一大小，做选择和对齐变换。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== ./data/mydataset/train_img/tock/tock!90.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor8.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor3.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor9.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor5.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock11.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor10.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock12.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock7.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor13.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock2.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock3.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock!45.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock!67.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor7.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor4.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock13.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor1.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock9.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock4.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock8.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor2.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor15.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock14.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor6.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor12.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock6.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock1.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock5.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor14.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor11.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock10.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock!22.jpg ===\n"
     ]
    }
   ],
   "source": [
    "#!for N in {1..8}; do ~/openface/util/align-dlib.py ./data/mydataset/raw/sj align outerEyesAndNose ./output --size 96 & done >shell.log\n",
    "!~/openface/util/align-dlib.py ./data/mydataset/train_img align outerEyesAndNose ./data/mydataset/aligned_img --size 96   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Generate Representations\n",
    "提取特征点的luajit脚本，需要注意的是需要归类命名好资源文件， 这样输出格式化的带标签的tensor 提供给 之后的SVM学习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  data : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/data/mydataset/aligned_img\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  imgDim : \u001b[0;36m96\u001b[0m\n",
      "  model : \u001b[1;30m\"\u001b[0m\u001b[0;32m/root/openface/models/openface/nn4.small2.v1.t7\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  device : \u001b[0;36m1\u001b[0m\n",
      "  outDir : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  cache : \u001b[0;34mfalse\u001b[0m\n",
      "  cuda : \u001b[0;34mfalse\u001b[0m\n",
      "  batchSize : \u001b[0;36m50\u001b[0m\n",
      "}\n",
      "\u001b[0m/mnt/data/mydataset/aligned_img\u001b[0m\t\n",
      "\u001b[0mcache lotation: \u001b[0m\t\u001b[0m/mnt/data/mydataset/aligned_img/cache.t7\u001b[0m\t\n",
      "\u001b[0mLoading metadata from cache.\u001b[0m\t\n",
      "\u001b[0mIf your dataset has changed, delete the cache file.\u001b[0m\t\n",
      "\u001b[0mnImgs: \u001b[0m\t\u001b[0;36m32\u001b[0m\t\n",
      "\u001b[0mRepresent: 32/32\u001b[0m\t\n"
     ]
    }
   ],
   "source": [
    "!~/openface/batch-represent/main.lua -outDir /mnt -data /mnt/data/mydataset/aligned_img"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Create the Classification Model\n",
    "SVM的训练速度很快，这表示他可能被动态的应用到移动设备的场景。比如零时添加一个人脸等场景。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading embeddings.\r\n",
      "Training for 2 classes.\r\n",
      "Saving classifier to './classifier.pkl'\r\n"
     ]
    }
   ],
   "source": [
    "! ~/openface/demos/classifier.py train ."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Classifying New Images\n",
    "* 使用新的模型，这里 使用了2个人数据集（tock,trevor） 没人不同角度表情光线条件下，共17张照片， 取出其中三张作为测试集并在测试集中加入真实拍摄的陌生人。此demo中需删除无法识别人脸的图片\n",
    "* 结果,很大程度上对未预处理照片找不到人脸位置，未预处理照片识别时间比较慢，置信度不高，对不同人可能出现0.8的高分。\n",
    "* 总的来说这例适合工作在 ，简单背景如验证机，一对一使用如快速人工核验红黑名单人员。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=== ./data/mydataset/test_img/A.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict trevor with 0.51 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/C1.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict trevor with 0.81 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/H1.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict trevor with 0.60 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/H3.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.72 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/Q3.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict trevor with 0.61 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock15.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.99 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock16.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.99 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock17.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.99 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/trevor16.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict trevor with 0.72 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/trevor17.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict trevor with 0.91 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/trevor18.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict trevor with 0.83 confidence.\n"
     ]
    }
   ],
   "source": [
    "!~/openface/demos/classifier.py infer ./classifier.pkl ./data/mydataset/test_img/*\n",
    "#{tock,trevor,other}*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "# 结论 \n",
    "* 一号人物测试数据为正脸，三张识别率均为0.99\n",
    "* 二号人物测试数据为正脸 ，识别律分别为0.72，0.83，0.91\n",
    "* 对齐测试数据的人脸在提高识别率上会起反作用。 对齐人脸除了在提高训练速度上的作用其外其他特性还有待研究"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "![hello world](d:/01.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== ./data/mydataset/test_img/tock17.jpg ===\n",
      "=== ./data/mydataset/test_img/H1.jpg ===\n",
      "=== ./data/mydataset/test_img/A.jpg ===\n",
      "=== ./data/mydataset/test_img/tock16.jpg ===\n",
      "=== ./data/mydataset/test_img/trevor18.jpg ===\n",
      "=== ./data/mydataset/test_img/trevor16.jpg ===\n",
      "=== ./data/mydataset/test_img/C1.jpg ===\n",
      "^C\n",
      "Traceback (most recent call last):\n",
      "  File \"/root/openface/util/align-dlib.py\", line 174, in <module>\n",
      "    alignMain(args)\n",
      "  File \"/root/openface/util/align-dlib.py\", line 118, in alignMain\n",
      "    skipMulti=args.skipMulti)\n",
      "  File \"/usr/local/lib/python2.7/dist-packages/openface/align_dlib.py\", line 175, in align\n",
      "    bb = self.getLargestFaceBoundingBox(rgbImg, skipMulti)\n",
      "  File \"/usr/local/lib/python2.7/dist-packages/openface/align_dlib.py\", line 123, in getLargestFaceBoundingBox\n",
      "    faces = self.getAllFaceBoundingBoxes(rgbImg)\n",
      "  File \"/usr/local/lib/python2.7/dist-packages/openface/align_dlib.py\", line 104, in getAllFaceBoundingBoxes\n",
      "    return self.detector(rgbImg, 1)\n",
      "KeyboardInterrupt\n"
     ]
    }
   ],
   "source": [
    "!~/openface/util/align-dlib.py ./data/mydataset/test_img align outerEyesAndNose ./data/mydataset/test_aligned_img --size 96   \n",
    "! mv ./data/mydataset/test_aligned_img/* ../ "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=== ./data/mydataset/test_aligned_img/H3.png ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.59 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_aligned_img/Q3.png ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.73 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_aligned_img/tock15.png ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.98 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_aligned_img/tock16.png ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.99 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_aligned_img/tock17.png ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.98 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_aligned_img/trevor16.png ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict trevor with 0.70 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_aligned_img/trevor17.png ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict trevor with 0.90 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_aligned_img/trevor18.png ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict trevor with 0.73 confidence.\n"
     ]
    }
   ],
   "source": [
    "!~/openface/demos/classifier.py infer ./classifier.pkl ./data/mydataset/test_aligned_img/*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 测试数据 "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.1.1 demo测试数据\n",
    "{} 在jupyershell中支持有问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/bin/sh: 1: ~/openface/demos/classifier.py infer ~/openface/models/openface/celeb-classifier.nn4.small2.v1.pkl ~/openface/images/examples/{carell,adams,lennon}*: not found\r\n"
     ]
    }
   ],
   "source": [
    "!~/openface/demos/classifier.py infer ~/openface/models/openface/celeb-classifier.nn4.small2.v1.pkl ~/openface/images/examples/*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2.1.2 本地数据集测试 \n",
    "\n",
    "准备好本地照片数据，X:\\share\\image\\train_id_img_label  所有数据根据身份证号存放到文件夹中  共2967张 去掉重复2937张\n",
    "* 训练并测试 训练所需时间， \n",
    "* 在测试集中，识别出指定人\"王飞\"的时间和精度\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  data : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/data/wangli/train_id_img_label\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  imgDim : \u001b[0;36m96\u001b[0m\n",
      "  model : \u001b[1;30m\"\u001b[0m\u001b[0;32m/root/openface/models/openface/nn4.small2.v1.t7\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  device : \u001b[0;36m1\u001b[0m\n",
      "  outDir : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/output/wangli\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  cache : \u001b[0;34mfalse\u001b[0m\n",
      "  cuda : \u001b[0;34mfalse\u001b[0m\n",
      "  batchSize : \u001b[0;36m50\u001b[0m\n",
      "}\n",
      "\u001b[0m/mnt/data/wangli/train_id_img_label\u001b[0m\t\n",
      "\u001b[0mcache lotation: \u001b[0m\t\u001b[0m/mnt/data/wangli/train_id_img_label/cache.t7\u001b[0m\t\n",
      "\u001b[0mCreating metadata for cache.\u001b[0m\t\n",
      "{\n",
      "  sampleSize : \n",
      "    {\n",
      "      1 : \u001b[0;36m3\u001b[0m\n",
      "      2 : \u001b[0;36m96\u001b[0m\n",
      "      3 : \u001b[0;36m96\u001b[0m\n",
      "    }\n",
      "  split : \u001b[0;36m0\u001b[0m\n",
      "  verbose : \u001b[0;34mtrue\u001b[0m\n",
      "  paths : \n",
      "    {\n",
      "      1 : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/data/wangli/train_id_img_label\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "    }\n",
      "  samplingMode : \u001b[1;30m\"\u001b[0m\u001b[0;32mbalanced\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  loadSize : \n",
      "    {\n",
      "      1 : \u001b[0;36m3\u001b[0m\n",
      "      2 : \u001b[0;36m96\u001b[0m\n",
      "      3 : \u001b[0;36m96\u001b[0m\n",
      "    }\n",
      "}\n",
      "\u001b[0mrunning \"find\" on each class directory, and concatenate all those filenames into a single file containing all image paths for a given class\u001b[0m\t\n",
      "\u001b[0mnow combine all the files to a single large file\u001b[0m\t\n",
      "\u001b[0mload the large concatenated list of sample paths to self.imagePath\u001b[0m\t\n",
      "\u001b[0m2937 samples found.\u001b[0m\t....................]                              ETA: 0ms | Step: 0m 0/2937 \n",
      "\u001b[0mUpdating classList and imageClass appropriately\u001b[0m\t\n",
      " [=============================================>]                              Tot: 24s275ms | Step: 9 2937/2937 7 \n",
      "\u001b[0mCleaning up temporary files\u001b[0m\t\n",
      "\u001b[0mSplitting training and test sets to a ratio of 0/100\u001b[0m\t\n",
      "\u001b[0mnImgs: \u001b[0m\t\u001b[0;36m2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 50/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 100/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 150/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 200/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 250/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 300/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 350/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 400/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 450/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 500/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 550/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 600/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 650/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 700/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 750/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 800/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 850/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 900/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 950/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1000/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1050/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1100/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1150/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1200/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1250/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1300/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1350/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1400/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1450/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1500/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1550/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1600/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1650/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1700/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1750/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1800/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1850/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1900/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 1950/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2000/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2050/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2100/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2150/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2200/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2250/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2300/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2350/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2400/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2450/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2500/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2550/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2600/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2650/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2700/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2750/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2800/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2850/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2900/2937\u001b[0m\t\n",
      "\u001b[0mRepresent: 2937/2937\u001b[0m\t\n"
     ]
    }
   ],
   "source": [
    "#提取特征点 \n",
    "# 对齐的人脸 变少了很多 解决方法，\n",
    "#不使用归一化数据\n",
    "#!~/openface/util/align-dlib.py ./data/wangli/train_id_img_label align outerEyesAndNose ./data/wangli/aligned_img --size 96\n",
    "import os\n",
    "if os.path.exists( r\"/mnt/data/wangli/train_id_img_label/cache.t7\"):os.remove(r\"/mnt/data/wangli/train_id_img_label/cache.t7\")\n",
    "!~/openface/batch-represent/main.lua -outDir /mnt/output/wangli  -data /mnt/data/wangli/train_id_img_label"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading embeddings.\n",
      "Training for 2937 classes.\n",
      "Saving classifier to '/mnt/output/wangli/classifier.pkl'\n",
      "CPU times: user 1.85 s, sys: 270 ms, total: 2.12 s\n",
      "Wall time: 1min 59s\n"
     ]
    }
   ],
   "source": [
    "%time ! ~/openface/demos/classifier.py train  /mnt/output/wangli"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=== /mnt/data/wangli/test_img/Q1.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 511111197602130425 with 0.00 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q2.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 511111197602130425 with 0.00 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q3.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 653125197108121022 with 0.00 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q4.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 511111197602130425 with 0.00 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q5.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 653221194408160046 with 0.00 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q6.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 653125197108121022 with 0.00 confidence.\n",
      "CPU times: user 350 ms, sys: 70 ms, total: 420 ms\n",
      "Wall time: 19.5 s\n"
     ]
    }
   ],
   "source": [
    "#无法识别出\n",
    "%time !~/openface/demos/classifier.py infer /mnt/output/wangli/classifier.pkl /mnt/data/wangli/test_img/*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 使用归一化数据\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  data : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/data/wangli/aligned_img\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  imgDim : \u001b[0;36m96\u001b[0m\n",
      "  model : \u001b[1;30m\"\u001b[0m\u001b[0;32m/root/openface/models/openface/nn4.small2.v1.t7\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  device : \u001b[0;36m1\u001b[0m\n",
      "  outDir : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/output/wangli\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  cache : \u001b[0;34mfalse\u001b[0m\n",
      "  cuda : \u001b[0;34mfalse\u001b[0m\n",
      "  batchSize : \u001b[0;36m50\u001b[0m\n",
      "}\n",
      "\u001b[0m/mnt/data/wangli/aligned_img\u001b[0m\t\n",
      "\u001b[0mcache lotation: \u001b[0m\t\u001b[0m/mnt/data/wangli/aligned_img/cache.t7\u001b[0m\t\n",
      "\u001b[0mCreating metadata for cache.\u001b[0m\t\n",
      "{\n",
      "  sampleSize : \n",
      "    {\n",
      "      1 : \u001b[0;36m3\u001b[0m\n",
      "      2 : \u001b[0;36m96\u001b[0m\n",
      "      3 : \u001b[0;36m96\u001b[0m\n",
      "    }\n",
      "  split : \u001b[0;36m0\u001b[0m\n",
      "  verbose : \u001b[0;34mtrue\u001b[0m\n",
      "  paths : \n",
      "    {\n",
      "      1 : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/data/wangli/aligned_img\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "    }\n",
      "  samplingMode : \u001b[1;30m\"\u001b[0m\u001b[0;32mbalanced\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  loadSize : \n",
      "    {\n",
      "      1 : \u001b[0;36m3\u001b[0m\n",
      "      2 : \u001b[0;36m96\u001b[0m\n",
      "      3 : \u001b[0;36m96\u001b[0m\n",
      "    }\n",
      "}\n",
      "\u001b[0mrunning \"find\" on each class directory, and concatenate all those filenames into a single file containing all image paths for a given class\u001b[0m\t\n",
      "\u001b[0mnow combine all the files to a single large file\u001b[0m\t\n",
      "\u001b[0mload the large concatenated list of sample paths to self.imagePath\u001b[0m\t\n",
      "\u001b[0m5 samples found.\u001b[0m\t.......................]                              ETA: 0ms | Step: 0m 0/5 \n",
      "\u001b[0mUpdating classList and imageClass appropriately\u001b[0m\t\n",
      " [=============================================>]                              Tot: 33ms | Step: 6 5/5 \n",
      "\u001b[0mCleaning up temporary files\u001b[0m\t\n",
      "\u001b[0mSplitting training and test sets to a ratio of 0/100\u001b[0m\t\n",
      "\u001b[0mnImgs: \u001b[0m\t\u001b[0;36m5\u001b[0m\t\n",
      "\u001b[0mRepresent: 5/5\u001b[0m\t\n"
     ]
    }
   ],
   "source": [
    "#!~/openface/util/align-dlib.py ./data/wangli/train_id_img_label align outerEyesAndNose ./data/wangli/aligned_img --size 96\n",
    "\n",
    "import os\n",
    "if os.path.exists( r\"/mnt/data/wangli/train_id_img_label/cache.t7\"):os.remove(r\"/mnt/data/wangli/train_id_img_label/cache.t7\");print(\"del cache\")\n",
    "!~/openface/batch-represent/main.lua -outDir /mnt/output/wangli  -data /mnt/data/wangli/aligned_img"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading embeddings.\n",
      "Training for 5 classes.\n",
      "Saving classifier to '/mnt/output/wangli/classifier.pkl'\n",
      "CPU times: user 60 ms, sys: 20 ms, total: 80 ms\n",
      "Wall time: 3.43 s\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q1.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.22 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q2.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.23 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q3.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199204090042 with 0.22 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q4.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.23 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q5.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.23 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q6.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199204090042 with 0.22 confidence.\n",
      "CPU times: user 190 ms, sys: 60 ms, total: 250 ms\n",
      "Wall time: 11 s\n"
     ]
    }
   ],
   "source": [
    "%time ! ~/openface/demos/classifier.py train  /mnt/output/wangli\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=== /mnt/data/wangli/test_img/A2.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.22 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/C3.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.25 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/F4.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.24 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/H4.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.24 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q1.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.22 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q2.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.23 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q3.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199204090042 with 0.22 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q4.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.23 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q5.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.23 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Q6.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199204090042 with 0.22 confidence.\n",
      "\n",
      "=== /mnt/data/wangli/test_img/Y2.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict 652923199908053346 with 0.23 confidence.\n",
      "CPU times: user 280 ms, sys: 110 ms, total: 390 ms\n",
      "Wall time: 17.2 s\n"
     ]
    }
   ],
   "source": [
    "\n",
    "%time !~/openface/demos/classifier.py infer /mnt/output/wangli/classifier.pkl /mnt/data/wangli/test_img/*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 结论  \n",
    "\n",
    "在2次训练后\n",
    "1 使用2973张网力图片 其中包含目标图片，不经过归一化处理\n",
    "\n",
    "2 使用5张归一化后的图片，包含一张目标图片\n",
    "\n",
    "以上均不能识别成功\n",
    "1：N 的分类识别方法需要数据支持。网力的身份证照片是81*100 96dpi 1张 不足以用openface 识别\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 用网络数据集 测试 openface 的识别速度\n",
    "* 102人的已知照片  每个人有1-3张作为训练数据，测试算法对其中一人的 识别速度\n",
    "* 使用openface.ipynb notebook 打标签测试数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== ./data/mydataset/train_img/adrian/adrian3.jpg ===\n",
      "=== ./data/mydataset/train_img/merilyn/merilyn1.jpg ===\n",
      "=== ./data/mydataset/train_img/scott/scott3.jpg ===\n",
      "=== ./data/mydataset/train_img/pkyle/pkyle2.jpg ===\n",
      "=== ./data/mydataset/train_img/olive/olive3.jpg ===\n",
      "=== ./data/mydataset/train_img/dsmith/dsmith3.jpg ===\n",
      "=== ./data/mydataset/train_img/miranda/miranda4.jpg ===\n",
      "=== ./data/mydataset/train_img/gfindley/gfindley1.jpg ===\n",
      "=== ./data/mydataset/train_img/chris/chris3.jpg ===\n",
      "=== ./data/mydataset/train_img/bfegan/bfegan2.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael6.jpg ===\n",
      "=== ./data/mydataset/train_img/david_imray/david_imray1.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon5.jpg ===\n",
      "=== ./data/mydataset/train_img/pat/pat3.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul14.jpg ===\n",
      "=== ./data/mydataset/train_img/heather/heather4.jpg ===\n",
      "=== ./data/mydataset/train_img/lynn/lynn2.jpg ===\n",
      "=== ./data/mydataset/train_img/adrian/adrian2.jpg ===\n",
      "=== ./data/mydataset/train_img/scott/scott4.jpg ===\n",
      "=== ./data/mydataset/train_img/john_mccal/john_mccal1.jpg ===\n",
      "=== ./data/mydataset/train_img/jsheenan/jsheenan1.jpg ===\n",
      "=== ./data/mydataset/train_img/mnicholson/mnicholson3.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew11.jpg ===\n",
      "=== ./data/mydataset/train_img/stewart/stewart2.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen14.jpg ===\n",
      "=== ./data/mydataset/train_img/caroline/caroline1.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin14.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson5.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian10.jpg ===\n",
      "=== ./data/mydataset/train_img/mark/mark2.jpg ===\n",
      "=== ./data/mydataset/train_img/mnicholson/mnicholson1.jpg ===\n",
      "=== ./data/mydataset/train_img/jsheenan/jsheenan3.jpg ===\n",
      "=== ./data/mydataset/train_img/irene/irene1.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael13.jpg ===\n",
      "=== ./data/mydataset/train_img/anon_one/anon_one1.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine7.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy8.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin12.jpg ===\n",
      "=== ./data/mydataset/train_img/gordon/gordon2.jpg ===\n",
      "=== ./data/mydataset/train_img/dsmith/dsmith1.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor6.jpg ===\n",
      "=== ./data/mydataset/train_img/alister/alister4.jpg ===\n",
      "=== ./data/mydataset/train_img/blair/blair1.jpg ===\n",
      "=== ./data/mydataset/train_img/itaylor/itaylor1.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay12.jpg ===\n",
      "=== ./data/mydataset/train_img/graham_brown/graham_brown1.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim8.jpg ===\n",
      "=== ./data/mydataset/train_img/peter/peter6.jpg ===\n",
      "=== ./data/mydataset/train_img/pkyle/pkyle4.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy5.jpg ===\n",
      "=== ./data/mydataset/train_img/chris_harbron/chris_harbron1.jpg ===\n",
      "=== ./data/mydataset/train_img/brian_ho/brian_ho1.jpg ===\n",
      "=== ./data/mydataset/train_img/gordon/gordon3.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby8.jpg ===\n",
      "=== ./data/mydataset/train_img/stewart/stewart1.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin7.jpg ===\n",
      "=== ./data/mydataset/train_img/annanena/annanena1.jpg ===\n",
      "=== ./data/mydataset/train_img/lynn/lynn4.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul2.jpg ===\n",
      "=== ./data/mydataset/train_img/richard_hardwick/richard_hardwick1.jpg ===\n",
      "=== ./data/mydataset/train_img/dhawley/dhawley1.jpg ===\n",
      "=== ./data/mydataset/train_img/neilg/neilg.jpg ===\n",
      "=== ./data/mydataset/train_img/ruth/ruth1.jpg ===\n",
      "=== ./data/mydataset/train_img/ghall/ghall1.jpg ===\n",
      "=== ./data/mydataset/train_img/ghall/ghall2.jpg ===\n",
      "=== ./data/mydataset/train_img/dhawleyg/dhawleyg.jpg ===\n",
      "=== ./data/mydataset/train_img/miranda/miranda1.jpg ===\n",
      "=== ./data/mydataset/train_img/neil/neil2.jpg ===\n",
      "=== ./data/mydataset/train_img/kim/kim2.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock4.jpg ===\n",
      "=== ./data/mydataset/train_img/ghall/ghall3.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor10.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock12.jpg ===\n",
      "=== ./data/mydataset/train_img/peter/peter13.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen2.jpg ===\n",
      "=== ./data/mydataset/train_img/adrian/adrian1.jpg ===\n",
      "=== ./data/mydataset/train_img/joanna/joanna4.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay17.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin1.jpg ===\n",
      "=== ./data/mydataset/train_img/marieg/marieg.jpg ===\n",
      "=== ./data/mydataset/train_img/alister/alister2.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael8.jpg ===\n",
      "=== ./data/mydataset/train_img/scott/scott2.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty6.jpg ===\n",
      "=== ./data/mydataset/train_img/derek/derek1.jpg ===\n",
      "=== ./data/mydataset/train_img/neil/neil4.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa17.jpg ===\n",
      "=== ./data/mydataset/train_img/blaw/blaw1.jpg ===\n",
      "=== ./data/mydataset/train_img/blaw/blaw4.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay13.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa8.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david1.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul!45.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands12.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow3.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise16.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy12.jpg ===\n",
      "=== ./data/mydataset/train_img/chris/chris1.jpg ===\n",
      "=== ./data/mydataset/train_img/olive/olive2.jpg ===\n",
      "=== ./data/mydataset/train_img/pat/pat17.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin6.jpg ===\n",
      "=== ./data/mydataset/train_img/dhawley/dhawley3.jpg ===\n",
      "=== ./data/mydataset/train_img/alec/alec1.jpg ===\n",
      "=== ./data/mydataset/train_img/dave_faquhar/dave_faquhar1.jpg ===\n",
      "=== ./data/mydataset/train_img/clean_adrian/clean_adrian1.jpg ===\n",
      "=== ./data/mydataset/train_img/pat/pat13.jpg ===\n",
      "=== ./data/mydataset/train_img/kieran/kieran1.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy3.jpg ===\n",
      "=== ./data/mydataset/train_img/jsheenan/jsheenan2.jpg ===\n",
      "=== ./data/mydataset/train_img/neil/neil1.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry5.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock5.jpg ===\n",
      "=== ./data/mydataset/train_img/irene/irene4.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim!22.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow12.jpg ===\n",
      "=== ./data/mydataset/train_img/alison/alison3.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa4.jpg ===\n",
      "=== ./data/mydataset/train_img/alison/alison2.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty7.jpg ===\n",
      "=== ./data/mydataset/train_img/irene/irene3.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim17.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni17.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby5.jpg ===\n",
      "=== ./data/mydataset/train_img/itaylor/itaylor3.jpg ===\n",
      "=== ./data/mydataset/train_img/gfindley/gfindley3.jpg ===\n",
      "=== ./data/mydataset/train_img/peter_macgeorge/peter_macgeorge1.jpg ===\n",
      "=== ./data/mydataset/train_img/johannes/johannes1.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise6.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon!67.jpg ===\n",
      "=== ./data/mydataset/train_img/mmanson/mmanson10.jpg ===\n",
      "=== ./data/mydataset/train_img/johnny_page/johnny_page1.jpg ===\n",
      "=== ./data/mydataset/train_img/kim/kim3.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie7.jpg ===\n",
      "=== ./data/mydataset/train_img/bfegan/bfegan4.jpg ===\n",
      "=== ./data/mydataset/train_img/gordon/gordon4.jpg ===\n",
      "=== ./data/mydataset/train_img/joanna/joanna3.jpg ===\n",
      "=== ./data/mydataset/train_img/grant_cumming/grant_cumming1.jpg ===\n",
      "=== ./data/mydataset/train_img/heather/heather3.jpg ===\n",
      "=== ./data/mydataset/train_img/paol/paol1.jpg ===\n",
      "=== ./data/mydataset/train_img/mnicholson/mnicholson4.jpg ===\n",
      "=== ./data/mydataset/train_img/kim/kim1.jpg ===\n",
      "=== ./data/mydataset/train_img/dbell/dbell2.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow1.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands8.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew5.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy11.jpg ===\n",
      "=== ./data/mydataset/train_img/gfindley/gfindley2.jpg ===\n",
      "=== ./data/mydataset/train_img/terry_johnstone/terry_johnstone1.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise8.jpg ===\n",
      "=== ./data/mydataset/train_img/meggan/meggan1.jpg ===\n",
      "=== ./data/mydataset/train_img/graeme/graeme4.jpg ===\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== ./data/mydataset/train_img/peter/peter12.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni2.jpg ===\n",
      "=== ./data/mydataset/train_img/mark/mark4.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin2.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry1.jpg ===\n",
      "=== ./data/mydataset/train_img/kieran/kieran3.jpg ===\n",
      "=== ./data/mydataset/train_img/george/george1.jpg ===\n",
      "=== ./data/mydataset/train_img/derek/derek2.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor18.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie13.jpg ===\n",
      "=== ./data/mydataset/train_img/joanna/joanna1.jpg ===\n",
      "=== ./data/mydataset/train_img/lynn/lynn3.jpg ===\n",
      "=== ./data/mydataset/train_img/dbell/dbell1.jpg ===\n",
      "=== ./data/mydataset/train_img/alister/alister1.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick1.jpg ===\n",
      "=== ./data/mydataset/train_img/heatherg/heatherg.jpg ===\n",
      "=== ./data/mydataset/train_img/dbell/dbell3.jpg ===\n",
      "=== ./data/mydataset/train_img/john_thom/john_thom1.jpg ===\n",
      "=== ./data/mydataset/train_img/jsheenang/jsheenang.jpg ===\n",
      "=== ./data/mydataset/train_img/mark/mark3.jpg ===\n",
      "=== ./data/mydataset/train_img/chris/chris2.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david3.jpg ===\n",
      "=== ./data/mydataset/train_img/graeme/graeme3.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon!45.jpg ===\n",
      "=== ./data/mydataset/train_img/bfegan/bfegan1.jpg ===\n",
      "=== ./data/mydataset/train_img/miranda/miranda3.jpg ===\n",
      "=== ./data/mydataset/train_img/stewart/stewart3.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty4.jpg ===\n",
      "=== ./data/mydataset/train_img/itaylor/itaylor4.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni8.jpg ===\n",
      "=== ./data/mydataset/train_img/milly/milly1.jpg ===\n",
      "=== ./data/mydataset/train_img/kayg/kayg.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby7.jpg ===\n",
      "=== ./data/mydataset/train_img/olive/olive1.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy3.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian3.jpg ===\n",
      "=== ./data/mydataset/train_img/hack/hack.jpg ===\n",
      "=== ./data/mydataset/train_img/fiona_hogarth/fiona_hogarth1.jpg ===\n",
      "=== ./data/mydataset/train_img/dhawley/dhawley4.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands!67.jpg ===\n",
      "=== ./data/mydataset/train_img/blaw/blaw3.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson6.jpg ===\n",
      "=== ./data/mydataset/train_img/graeme/graeme2.jpg ===\n",
      "=== ./data/mydataset/train_img/heather/heather1.jpg ===\n",
      "=== ./data/mydataset/train_img/milly/milly2.jpg ===\n",
      "=== ./data/mydataset/train_img/derek/derek3.jpg ===\n",
      "=== ./data/mydataset/train_img/alison/alison4.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson!67.jpg ===\n",
      "=== ./data/mydataset/train_img/dougal_grant/dougal_grant1.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick13.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick8.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david13.jpg ===\n",
      "=== ./data/mydataset/train_img/fiona/fiona1.jpg ===\n",
      "=== ./data/mydataset/train_img/pkyle/pkyle3.jpg ===\n",
      "=== ./data/mydataset/train_img/lynn_james/lynn_james1.jpg ===\n",
      "=== ./data/mydataset/train_img/gillian/gillian1.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine15.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry7.jpg ===\n",
      "=== ./data/mydataset/train_img/graemeg/graemeg.jpg ===\n",
      "=== ./data/mydataset/train_img/dsmith/dsmith2.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew6.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine6.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie1.jpg ===\n",
      "=== ./data/mydataset/train_img/mmanson/mmanson12.jpg ===\n",
      "=== ./data/mydataset/train_img/kieran/kieran4.jpg ===\n",
      "=== ./data/mydataset/train_img/mmanson/mmanson14.jpg ===\n",
      "=== ./data/mydataset/train_img/chris_pin/chris_pin1.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian4.jpg ===\n",
      "=== ./data/mydataset/train_img/milly/milly3.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen4.jpg ===\n",
      "{\n",
      "  data : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/data/mydataset/aligned_img\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  imgDim : \u001b[0;36m96\u001b[0m\n",
      "  model : \u001b[1;30m\"\u001b[0m\u001b[0;32m/root/openface/models/openface/nn4.small2.v1.t7\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  device : \u001b[0;36m1\u001b[0m\n",
      "  outDir : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  cache : \u001b[0;34mfalse\u001b[0m\n",
      "  cuda : \u001b[0;34mfalse\u001b[0m\n",
      "  batchSize : \u001b[0;36m50\u001b[0m\n",
      "}\n",
      "\u001b[0m/mnt/data/mydataset/aligned_img\u001b[0m\t\n",
      "\u001b[0mcache lotation: \u001b[0m\t\u001b[0m/mnt/data/mydataset/aligned_img/cache.t7\u001b[0m\t\n",
      "\u001b[0mLoading metadata from cache.\u001b[0m\t\n",
      "\u001b[0mIf your dataset has changed, delete the cache file.\u001b[0m\t\n",
      "\u001b[0mnImgs: \u001b[0m\t\u001b[0;36m32\u001b[0m\t\n",
      "\u001b[0mRepresent: 32/32\u001b[0m\t\n"
     ]
    }
   ],
   "source": [
    "# 数据集  位置 D:\\docker\\mnt\\openface\\data\\mydataset\\train_img\n",
    "!~/openface/util/align-dlib.py ./data/mydataset/train_img align outerEyesAndNose ./data/mydataset/aligned_img --size 96 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  data : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/data/mydataset/aligned_img\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  imgDim : \u001b[0;36m96\u001b[0m\n",
      "  model : \u001b[1;30m\"\u001b[0m\u001b[0;32m/root/openface/models/openface/nn4.small2.v1.t7\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  device : \u001b[0;36m1\u001b[0m\n",
      "  outDir : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  cache : \u001b[0;34mfalse\u001b[0m\n",
      "  cuda : \u001b[0;34mfalse\u001b[0m\n",
      "  batchSize : \u001b[0;36m50\u001b[0m\n",
      "}\n",
      "\u001b[0m/mnt/data/mydataset/aligned_img\u001b[0m\t\n",
      "\u001b[0mcache lotation: \u001b[0m\t\u001b[0m/mnt/data/mydataset/aligned_img/cache.t7\u001b[0m\t\n",
      "\u001b[0mCreating metadata for cache.\u001b[0m\t\n",
      "{\n",
      "  sampleSize : \n",
      "    {\n",
      "      1 : \u001b[0;36m3\u001b[0m\n",
      "      2 : \u001b[0;36m96\u001b[0m\n",
      "      3 : \u001b[0;36m96\u001b[0m\n",
      "    }\n",
      "  split : \u001b[0;36m0\u001b[0m\n",
      "  verbose : \u001b[0;34mtrue\u001b[0m\n",
      "  paths : \n",
      "    {\n",
      "      1 : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/data/mydataset/aligned_img\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "    }\n",
      "  samplingMode : \u001b[1;30m\"\u001b[0m\u001b[0;32mbalanced\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  loadSize : \n",
      "    {\n",
      "      1 : \u001b[0;36m3\u001b[0m\n",
      "      2 : \u001b[0;36m96\u001b[0m\n",
      "      3 : \u001b[0;36m96\u001b[0m\n",
      "    }\n",
      "}\n",
      "\u001b[0mrunning \"find\" on each class directory, and concatenate all those filenames into a single file containing all image paths for a given class\u001b[0m\t\n",
      "\u001b[0mnow combine all the files to a single large file\u001b[0m\t\n",
      "\u001b[0mload the large concatenated list of sample paths to self.imagePath\u001b[0m\t\n",
      "\u001b[0m221 samples found.\u001b[0m\t.....................]                              ETA: 0ms | Step: 0m 0/221 \n",
      "\u001b[0mUpdating classList and imageClass appropriately\u001b[0m\t\n",
      " [=============================================>]                              Tot: 824ms | Step: 8m 99/99 \n",
      "\u001b[0mCleaning up temporary files\u001b[0m\t\n",
      "\u001b[0mSplitting training and test sets to a ratio of 0/100\u001b[0m\t\n",
      "\u001b[0mnImgs: \u001b[0m\t\u001b[0;36m221\u001b[0m\t\n",
      "\u001b[0mRepresent: 50/221\u001b[0m\t\n",
      "\u001b[0mRepresent: 100/221\u001b[0m\t\n",
      "\u001b[0mRepresent: 150/221\u001b[0m\t\n",
      "\u001b[0mRepresent: 200/221\u001b[0m\t\n",
      "\u001b[0mRepresent: 221/221\u001b[0m\t\n"
     ]
    }
   ],
   "source": [
    "!rm /mnt/data/mydataset/aligned_img/cache.t7 \n",
    "!~/openface/batch-represent/main.lua -outDir /mnt -data /mnt/data/mydataset/aligned_img"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading embeddings.\n",
      "Training for 99 classes.\n",
      "Saving classifier to './classifier.pkl'\n",
      "CPU times: user 30 ms, sys: 30 ms, total: 60 ms\n",
      "Wall time: 2.82 s\n"
     ]
    }
   ],
   "source": [
    "#99 人的分类总数\n",
    "%time ! ~/openface/demos/classifier.py train .\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  统计结果\n",
    "无法检测 超过67度的侧脸，跳过\n",
    "* 2 个实验对象 均无法 得出结果 是否是每个人的样本数量不够导致？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=== ./data/mydataset/test_img/tock!22.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tracy with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock!45.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict stewart with 0.04 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock!67.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict stewart with 0.04 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock1.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict iroy with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock10.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict david with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock11.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict bfegan with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock13.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict david with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock14.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict iroy with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock15.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tracy with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock16.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict paul with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock17.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict itaylor with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock2.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict iroy with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock3.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict bfegan with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock6.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict bfegan with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock7.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict bfegan with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock8.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict david with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock9.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict david with 0.03 confidence.\n",
      "CPU times: user 90 ms, sys: 40 ms, total: 130 ms\n",
      "Wall time: 5.79 s\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy1.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict lynn with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy11.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict marie with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy13.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict marie with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy14.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict marie with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy2.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict lynn with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy4.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict lynn with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy5.jpg ===\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict lynn with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy6.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict marie with 0.04 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy7.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict marie with 0.03 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy9.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict lynn with 0.03 confidence.\n",
      "CPU times: user 90 ms, sys: 20 ms, total: 110 ms\n",
      "Wall time: 4.52 s\n"
     ]
    }
   ],
   "source": [
    "%time !~/openface/demos/classifier.py infer ./classifier.pkl ./data/mydataset/test_img/tock*\n",
    "%time !~/openface/demos/classifier.py infer ./classifier.pkl ./data/mydataset/test_img/tracy*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 将每个人的训练数据增加到9 继续尝试 不足九个则只训练不测试\n",
    "手动删除之前的文件\n",
    "* 训练用时3.38s 427张图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== ./data/mydataset/train_img/pat/pat15.jpg ===\n",
      "=== ./data/mydataset/train_img/mnicholson/mnicholson1.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy3.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry11.jpg ===\n",
      "=== ./data/mydataset/train_img/olive/olive2.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy8.jpg ===\n",
      "=== ./data/mydataset/train_img/pat/pat6.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock8.jpg ===\n",
      "=== ./data/mydataset/train_img/pkyle/pkyle1.jpg ===\n",
      "=== ./data/mydataset/train_img/joanna/joanna3.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie14.jpg ===\n",
      "=== ./data/mydataset/train_img/mnicholson/mnicholson4.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry13.jpg ===\n",
      "=== ./data/mydataset/train_img/adrian/adrian1.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin5.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim2.jpg ===\n",
      "=== ./data/mydataset/train_img/bfegan/bfegan3.jpg ===\n",
      "=== ./data/mydataset/train_img/derek/derek3.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick11.jpg ===\n",
      "=== ./data/mydataset/train_img/lynn/lynn2.jpg ===\n",
      "=== ./data/mydataset/train_img/ruth/ruth1.jpg ===\n",
      "=== ./data/mydataset/train_img/chris/chris4.jpg ===\n",
      "=== ./data/mydataset/train_img/brian_ho/brian_ho1.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise10.jpg ===\n",
      "=== ./data/mydataset/train_img/dougal_grant/dougal_grant1.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise7.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim9.jpg ===\n",
      "=== ./data/mydataset/train_img/john_mccal/john_mccal1.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay1.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty11.jpg ===\n",
      "=== ./data/mydataset/train_img/scott/scott1.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow14.jpg ===\n",
      "=== ./data/mydataset/train_img/heatherg/heatherg.jpg ===\n",
      "=== ./data/mydataset/train_img/dbell/dbell3.jpg ===\n",
      "=== ./data/mydataset/train_img/stewart/stewart3.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon2.jpg ===\n",
      "=== ./data/mydataset/train_img/alister/alister1.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni18.jpg ===\n",
      "=== ./data/mydataset/train_img/chris/chris3.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa8.jpg ===\n",
      "=== ./data/mydataset/train_img/dhawleyg/dhawleyg.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen!45.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby11.jpg ===\n",
      "=== ./data/mydataset/train_img/kim/kim4.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim8.jpg ===\n",
      "=== ./data/mydataset/train_img/alister/alister2.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson!90.jpg ===\n",
      "=== ./data/mydataset/train_img/peter/peter3.jpg ===\n",
      "=== ./data/mydataset/train_img/blaw/blaw1.jpg ===\n",
      "=== ./data/mydataset/train_img/pat/pat13.jpg ===\n",
      "=== ./data/mydataset/train_img/gfindley/gfindley1.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay6.jpg ===\n",
      "=== ./data/mydataset/train_img/irene/irene2.jpg ===\n",
      "=== ./data/mydataset/train_img/mark/mark1.jpg ===\n",
      "=== ./data/mydataset/train_img/blaw/blaw4.jpg ===\n",
      "=== ./data/mydataset/train_img/pat/pat10.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick3.jpg ===\n",
      "=== ./data/mydataset/train_img/mmanson/mmanson6.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa7.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul6.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa5.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock15.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock!90.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands2.jpg ===\n",
      "=== ./data/mydataset/train_img/peter/peter8.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy10.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty10.jpg ===\n",
      "=== ./data/mydataset/train_img/heather/heather3.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor9.jpg ===\n",
      "=== ./data/mydataset/train_img/derek/derek4.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine17.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul3.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby10.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty9.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine6.jpg ===\n",
      "=== ./data/mydataset/train_img/blaw/blaw3.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor8.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul!45.jpg ===\n",
      "=== ./data/mydataset/train_img/paol/paol1.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul5.jpg ===\n",
      "=== ./data/mydataset/train_img/irene/irene4.jpg ===\n",
      "=== ./data/mydataset/train_img/neil/neil2.jpg ===\n",
      "=== ./data/mydataset/train_img/jsheenang/jsheenang.jpg ===\n",
      "=== ./data/mydataset/train_img/irene/irene3.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael14.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim3.jpg ===\n",
      "=== ./data/mydataset/train_img/dave_faquhar/dave_faquhar1.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni1.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy5.jpg ===\n",
      "=== ./data/mydataset/train_img/ghall/ghall2.jpg ===\n",
      "=== ./data/mydataset/train_img/alison/alison1.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie12.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor17.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow8.jpg ===\n",
      "=== ./data/mydataset/train_img/graeme/graeme4.jpg ===\n",
      "=== ./data/mydataset/train_img/hack/hack.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock6.jpg ===\n",
      "=== ./data/mydataset/train_img/chris/chris1.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise15.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry17.jpg ===\n",
      "=== ./data/mydataset/train_img/gordon/gordon1.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin14.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor12.jpg ===\n",
      "=== ./data/mydataset/train_img/adrian/adrian3.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian5.jpg ===\n",
      "=== ./data/mydataset/train_img/jsheenan/jsheenan4.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine4.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david10.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim14.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry8.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni16.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon3.jpg ===\n",
      "=== ./data/mydataset/train_img/gfindley/gfindley2.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie17.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni11.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian12.jpg ===\n",
      "=== ./data/mydataset/train_img/pkyle/pkyle3.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni10.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow12.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul!90.jpg ===\n",
      "=== ./data/mydataset/train_img/blair/blair1.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty8.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick1.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen4.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin3.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon9.jpg ===\n",
      "=== ./data/mydataset/train_img/gfindley/gfindley4.jpg ===\n",
      "=== ./data/mydataset/train_img/blaw/blaw2.jpg ===\n",
      "=== ./data/mydataset/train_img/pat/pat2.jpg ===\n",
      "=== ./data/mydataset/train_img/dsmith/dsmith3.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon13.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson13.jpg ===\n",
      "=== ./data/mydataset/train_img/peter/peter4.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael15.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david5.jpg ===\n",
      "=== ./data/mydataset/train_img/mmanson/mmanson8.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock2.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa6.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin15.jpg ===\n",
      "=== ./data/mydataset/train_img/lynn/lynn4.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim5.jpg ===\n",
      "=== ./data/mydataset/train_img/fiona/fiona1.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry6.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow4.jpg ===\n",
      "=== ./data/mydataset/train_img/lynn_james/lynn_james1.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty7.jpg ===\n",
      "=== ./data/mydataset/train_img/miranda/miranda2.jpg ===\n",
      "=== ./data/mydataset/train_img/chris_pin/chris_pin1.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin11.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin10.jpg ===\n",
      "=== ./data/mydataset/train_img/scott/scott3.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon!67.jpg ===\n",
      "=== ./data/mydataset/train_img/mnicholson/mnicholson2.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry12.jpg ===\n",
      "=== ./data/mydataset/train_img/stewart/stewart4.jpg ===\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== ./data/mydataset/train_img/dhawley/dhawley3.jpg ===\n",
      "=== ./data/mydataset/train_img/meggan/meggan1.jpg ===\n",
      "=== ./data/mydataset/train_img/miranda/miranda3.jpg ===\n",
      "=== ./data/mydataset/train_img/david_imray/david_imray1.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew13.jpg ===\n",
      "=== ./data/mydataset/train_img/mmanson/mmanson4.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby5.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa9.jpg ===\n",
      "=== ./data/mydataset/train_img/alison/alison3.jpg ===\n",
      "=== ./data/mydataset/train_img/pkyle/pkyle4.jpg ===\n",
      "=== ./data/mydataset/train_img/peter/peter7.jpg ===\n",
      "=== ./data/mydataset/train_img/heather/heather1.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon6.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen!67.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty18.jpg ===\n",
      "=== ./data/mydataset/train_img/lynn/lynn1.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock17.jpg ===\n",
      "=== ./data/mydataset/train_img/irene/irene1.jpg ===\n",
      "=== ./data/mydataset/train_img/dsmith/dsmith2.jpg ===\n",
      "=== ./data/mydataset/train_img/gordon/gordon4.jpg ===\n",
      "=== ./data/mydataset/train_img/olive/olive4.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael18.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy1.jpg ===\n",
      "=== ./data/mydataset/train_img/graemeg/graemeg.jpg ===\n",
      "=== ./data/mydataset/train_img/dsmith/dsmith1.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow1.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor5.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay3.jpg ===\n",
      "=== ./data/mydataset/train_img/joanna/joanna2.jpg ===\n",
      "=== ./data/mydataset/train_img/olive/olive1.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise18.jpg ===\n",
      "=== ./data/mydataset/train_img/stewart/stewart2.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick18.jpg ===\n",
      "=== ./data/mydataset/train_img/scott/scott4.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew11.jpg ===\n",
      "=== ./data/mydataset/train_img/neil/neil1.jpg ===\n",
      "=== ./data/mydataset/train_img/derek/derek1.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine5.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson6.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick2.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul13.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow3.jpg ===\n",
      "=== ./data/mydataset/train_img/milly/milly4.jpg ===\n",
      "=== ./data/mydataset/train_img/john_thom/john_thom1.jpg ===\n",
      "=== ./data/mydataset/train_img/peter/peter2.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david14.jpg ===\n",
      "=== ./data/mydataset/train_img/alister/alister4.jpg ===\n",
      "=== ./data/mydataset/train_img/mark/mark4.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby6.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands7.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni13.jpg ===\n",
      "=== ./data/mydataset/train_img/pat/pat7.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael8.jpg ===\n",
      "=== ./data/mydataset/train_img/peter/peter10.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine9.jpg ===\n",
      "=== ./data/mydataset/train_img/dbell/dbell4.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy14.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen18.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine12.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick16.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin16.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands!22.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay2.jpg ===\n",
      "=== ./data/mydataset/train_img/bfegan/bfegan4.jpg ===\n",
      "=== ./data/mydataset/train_img/terry_johnstone/terry_johnstone1.jpg ===\n",
      "=== ./data/mydataset/train_img/pat/pat4.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy6.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise2.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie16.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew14.jpg ===\n",
      "=== ./data/mydataset/train_img/graeme/graeme1.jpg ===\n",
      "=== ./data/mydataset/train_img/pkyle/pkyle2.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy2.jpg ===\n",
      "=== ./data/mydataset/train_img/graeme/graeme2.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david11.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands!45.jpg ===\n",
      "=== ./data/mydataset/train_img/pat/pat8.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon!22.jpg ===\n",
      "=== ./data/mydataset/train_img/mmanson/mmanson11.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim4.jpg ===\n",
      "=== ./data/mydataset/train_img/mnicholson/mnicholson3.jpg ===\n",
      "=== ./data/mydataset/train_img/miranda/miranda4.jpg ===\n",
      "=== ./data/mydataset/train_img/itaylor/itaylor1.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni14.jpg ===\n",
      "=== ./data/mydataset/train_img/bfegan/bfegan1.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa12.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy9.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian2.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands!67.jpg ===\n",
      "=== ./data/mydataset/train_img/adrian/adrian4.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy11.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew!45.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin4.jpg ===\n",
      "=== ./data/mydataset/train_img/pat/pat9.jpg ===\n",
      "=== ./data/mydataset/train_img/gordon/gordon2.jpg ===\n",
      "=== ./data/mydataset/train_img/derek/derek2.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine16.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen12.jpg ===\n",
      "=== ./data/mydataset/train_img/clean_adrian/clean_adrian1.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen!90.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie6.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock7.jpg ===\n",
      "=== ./data/mydataset/train_img/neilg/neilg.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david12.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian3.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david16.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin6.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy4.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie7.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy1.jpg ===\n",
      "=== ./data/mydataset/train_img/kim/kim1.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine13.jpg ===\n",
      "=== ./data/mydataset/train_img/dbell/dbell2.jpg ===\n",
      "=== ./data/mydataset/train_img/dhawley/dhawley2.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy7.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david13.jpg ===\n",
      "=== ./data/mydataset/train_img/richard_hardwick/richard_hardwick1.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise6.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie15.jpg ===\n",
      "=== ./data/mydataset/train_img/alec/alec1.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby18.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin14.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy2.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands14.jpg ===\n",
      "=== ./data/mydataset/train_img/johannes/johannes1.jpg ===\n",
      "=== ./data/mydataset/train_img/mark/mark2.jpg ===\n",
      "=== ./data/mydataset/train_img/kieran/kieran2.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry16.jpg ===\n",
      "=== ./data/mydataset/train_img/anon_one/anon_one1.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin13.jpg ===\n",
      "=== ./data/mydataset/train_img/graeme/graeme3.jpg ===\n",
      "=== ./data/mydataset/train_img/jsheenan/jsheenan1.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian11.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy12.jpg ===\n",
      "=== ./data/mydataset/train_img/kayg/kayg.jpg ===\n",
      "=== ./data/mydataset/train_img/itaylor/itaylor2.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick7.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy4.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin5.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay15.jpg ===\n",
      "=== ./data/mydataset/train_img/miranda/miranda1.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow13.jpg ===\n",
      "=== ./data/mydataset/train_img/mmanson/mmanson13.jpg ===\n",
      "=== ./data/mydataset/train_img/graham_brown/graham_brown1.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie18.jpg ===\n",
      "=== ./data/mydataset/train_img/george/george1.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow9.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise11.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise4.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon10.jpg ===\n",
      "=== ./data/mydataset/train_img/peter/peter12.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin2.jpg ===\n",
      "=== ./data/mydataset/train_img/jsheenan/jsheenan2.jpg ===\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== ./data/mydataset/train_img/mmanson/mmanson3.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor2.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew12.jpg ===\n",
      "=== ./data/mydataset/train_img/bfegan/bfegan2.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni12.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew9.jpg ===\n",
      "=== ./data/mydataset/train_img/peter/peter1.jpg ===\n",
      "=== ./data/mydataset/train_img/simon/simon7.jpg ===\n",
      "=== ./data/mydataset/train_img/catherine/catherine7.jpg ===\n",
      "=== ./data/mydataset/train_img/annanena/annanena1.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby15.jpg ===\n",
      "=== ./data/mydataset/train_img/heather/heather2.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay8.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson8.jpg ===\n",
      "=== ./data/mydataset/train_img/marieg/marieg.jpg ===\n",
      "=== ./data/mydataset/train_img/adrian/adrian2.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby16.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael17.jpg ===\n",
      "=== ./data/mydataset/train_img/peter_macgeorge/peter_macgeorge1.jpg ===\n",
      "=== ./data/mydataset/train_img/chris_harbron/chris_harbron1.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael7.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew!67.jpg ===\n",
      "=== ./data/mydataset/train_img/alison/alison2.jpg ===\n",
      "=== ./data/mydataset/train_img/louise/louise1.jpg ===\n",
      "=== ./data/mydataset/train_img/neil/neil3.jpg ===\n",
      "=== ./data/mydataset/train_img/marie/marie11.jpg ===\n",
      "=== ./data/mydataset/train_img/heather/heather4.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry14.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian4.jpg ===\n",
      "=== ./data/mydataset/train_img/milly/milly3.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin9.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty6.jpg ===\n",
      "=== ./data/mydataset/train_img/gillian/gillian1.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin1.jpg ===\n",
      "=== ./data/mydataset/train_img/kim/kim3.jpg ===\n",
      "=== ./data/mydataset/train_img/joanna/joanna1.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick14.jpg ===\n",
      "=== ./data/mydataset/train_img/lynn/lynn3.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa16.jpg ===\n",
      "=== ./data/mydataset/train_img/jsheenan/jsheenan3.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david18.jpg ===\n",
      "=== ./data/mydataset/train_img/johnny_page/johnny_page1.jpg ===\n",
      "=== ./data/mydataset/train_img/olive/olive3.jpg ===\n",
      "=== ./data/mydataset/train_img/ghall/ghall1.jpg ===\n",
      "=== ./data/mydataset/train_img/peter/peter13.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin7.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen11.jpg ===\n",
      "=== ./data/mydataset/train_img/scott/scott2.jpg ===\n",
      "=== ./data/mydataset/train_img/merilyn/merilyn1.jpg ===\n",
      "=== ./data/mydataset/train_img/kieran/kieran1.jpg ===\n",
      "=== ./data/mydataset/train_img/mark/mark3.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul11.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands12.jpg ===\n",
      "=== ./data/mydataset/train_img/dlow/dlow18.jpg ===\n",
      "=== ./data/mydataset/train_img/david/david3.jpg ===\n",
      "=== ./data/mydataset/train_img/tracy/tracy5.jpg ===\n",
      "=== ./data/mydataset/train_img/kieran/kieran4.jpg ===\n",
      "=== ./data/mydataset/train_img/joanna/joanna4.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul8.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock12.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian8.jpg ===\n",
      "=== ./data/mydataset/train_img/dhawley/dhawley4.jpg ===\n",
      "=== ./data/mydataset/train_img/alison/alison4.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay16.jpg ===\n",
      "=== ./data/mydataset/train_img/barry/barry9.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian13.jpg ===\n",
      "=== ./data/mydataset/train_img/dsmith/dsmith4.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson!22.jpg ===\n",
      "=== ./data/mydataset/train_img/kieran/kieran3.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael6.jpg ===\n",
      "=== ./data/mydataset/train_img/paul/paul10.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson10.jpg ===\n",
      "=== ./data/mydataset/train_img/ghall/ghall3.jpg ===\n",
      "=== ./data/mydataset/train_img/hin/hin17.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay4.jpg ===\n",
      "=== ./data/mydataset/train_img/martin/martin10.jpg ===\n",
      "=== ./data/mydataset/train_img/chris/chris2.jpg ===\n",
      "=== ./data/mydataset/train_img/ian/ian10.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew2.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa14.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen10.jpg ===\n",
      "=== ./data/mydataset/train_img/andrew/andrew7.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands6.jpg ===\n",
      "=== ./data/mydataset/train_img/alister/alister3.jpg ===\n",
      "=== ./data/mydataset/train_img/mmanson/mmanson9.jpg ===\n",
      "=== ./data/mydataset/train_img/fiona_hogarth/fiona_hogarth1.jpg ===\n",
      "=== ./data/mydataset/train_img/mmanson/mmanson1.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson1.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby9.jpg ===\n",
      "=== ./data/mydataset/train_img/tock/tock!45.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty15.jpg ===\n",
      "=== ./data/mydataset/train_img/lisa/lisa10.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael10.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor11.jpg ===\n",
      "=== ./data/mydataset/train_img/itaylor/itaylor3.jpg ===\n",
      "=== ./data/mydataset/train_img/kim/kim2.jpg ===\n",
      "=== ./data/mydataset/train_img/itaylor/itaylor4.jpg ===\n",
      "=== ./data/mydataset/train_img/nick/nick13.jpg ===\n",
      "=== ./data/mydataset/train_img/kirsty/kirsty4.jpg ===\n",
      "=== ./data/mydataset/train_img/ghall/ghall4.jpg ===\n",
      "=== ./data/mydataset/train_img/amellanby/amellanby13.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson!67.jpg ===\n",
      "=== ./data/mydataset/train_img/mmanson/mmanson5.jpg ===\n",
      "=== ./data/mydataset/train_img/milly/milly2.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor6.jpg ===\n",
      "=== ./data/mydataset/train_img/caroline/caroline1.jpg ===\n",
      "=== ./data/mydataset/train_img/grant_cumming/grant_cumming1.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim!22.jpg ===\n",
      "=== ./data/mydataset/train_img/kay/kay9.jpg ===\n",
      "=== ./data/mydataset/train_img/trevor/trevor1.jpg ===\n",
      "=== ./data/mydataset/train_img/michael/michael5.jpg ===\n",
      "=== ./data/mydataset/train_img/iroy/iroy6.jpg ===\n",
      "=== ./data/mydataset/train_img/milly/milly1.jpg ===\n",
      "=== ./data/mydataset/train_img/dbell/dbell1.jpg ===\n",
      "=== ./data/mydataset/train_img/dhands/dhands4.jpg ===\n",
      "=== ./data/mydataset/train_img/dhawley/dhawley1.jpg ===\n",
      "=== ./data/mydataset/train_img/jim/jim11.jpg ===\n",
      "=== ./data/mydataset/train_img/neil/neil4.jpg ===\n",
      "=== ./data/mydataset/train_img/stewart/stewart1.jpg ===\n",
      "=== ./data/mydataset/train_img/gordon/gordon3.jpg ===\n",
      "=== ./data/mydataset/train_img/jenni/jenni2.jpg ===\n",
      "=== ./data/mydataset/train_img/dpearson/dpearson12.jpg ===\n",
      "=== ./data/mydataset/train_img/gfindley/gfindley3.jpg ===\n",
      "=== ./data/mydataset/train_img/stephen/stephen2.jpg ===\n",
      "rm: cannot remove '/mnt/data/mydataset/aligned_img/cache.t7': No such file or directory\n",
      "{\n",
      "  data : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/data/mydataset/aligned_img\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  imgDim : \u001b[0;36m96\u001b[0m\n",
      "  model : \u001b[1;30m\"\u001b[0m\u001b[0;32m/root/openface/models/openface/nn4.small2.v1.t7\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  device : \u001b[0;36m1\u001b[0m\n",
      "  outDir : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  cache : \u001b[0;34mfalse\u001b[0m\n",
      "  cuda : \u001b[0;34mfalse\u001b[0m\n",
      "  batchSize : \u001b[0;36m50\u001b[0m\n",
      "}\n",
      "\u001b[0m/mnt/data/mydataset/aligned_img\u001b[0m\t\n",
      "\u001b[0mcache lotation: \u001b[0m\t\u001b[0m/mnt/data/mydataset/aligned_img/cache.t7\u001b[0m\t\n",
      "\u001b[0mCreating metadata for cache.\u001b[0m\t\n",
      "{\n",
      "  sampleSize : \n",
      "    {\n",
      "      1 : \u001b[0;36m3\u001b[0m\n",
      "      2 : \u001b[0;36m96\u001b[0m\n",
      "      3 : \u001b[0;36m96\u001b[0m\n",
      "    }\n",
      "  split : \u001b[0;36m0\u001b[0m\n",
      "  verbose : \u001b[0;34mtrue\u001b[0m\n",
      "  paths : \n",
      "    {\n",
      "      1 : \u001b[1;30m\"\u001b[0m\u001b[0;32m/mnt/data/mydataset/aligned_img\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "    }\n",
      "  samplingMode : \u001b[1;30m\"\u001b[0m\u001b[0;32mbalanced\u001b[0m\u001b[1;30m\"\u001b[0m\n",
      "  loadSize : \n",
      "    {\n",
      "      1 : \u001b[0;36m3\u001b[0m\n",
      "      2 : \u001b[0;36m96\u001b[0m\n",
      "      3 : \u001b[0;36m96\u001b[0m\n",
      "    }\n",
      "}\n",
      "\u001b[0mrunning \"find\" on each class directory, and concatenate all those filenames into a single file containing all image paths for a given class\u001b[0m\t\n",
      "\u001b[0mnow combine all the files to a single large file\u001b[0m\t\n",
      "\u001b[0mload the large concatenated list of sample paths to self.imagePath\u001b[0m\t\n",
      "\u001b[0m427 samples found.\u001b[0m\t.....................]                              ETA: 0ms | Step: 0m 0/427 \n",
      "\u001b[0mUpdating classList and imageClass appropriately\u001b[0m\t\n",
      " [=============================================>]                              Tot: 879ms | Step: 8m 99/99 \n",
      "\u001b[0mCleaning up temporary files\u001b[0m\t\n",
      "\u001b[0mSplitting training and test sets to a ratio of 0/100\u001b[0m\t\n",
      "\u001b[0mnImgs: \u001b[0m\t\u001b[0;36m427\u001b[0m\t\n",
      "\u001b[0mRepresent: 50/427\u001b[0m\t\n",
      "\u001b[0mRepresent: 100/427\u001b[0m\t\n",
      "\u001b[0mRepresent: 150/427\u001b[0m\t\n",
      "\u001b[0mRepresent: 200/427\u001b[0m\t\n",
      "\u001b[0mRepresent: 250/427\u001b[0m\t\n",
      "\u001b[0mRepresent: 300/427\u001b[0m\t\n",
      "\u001b[0mRepresent: 350/427\u001b[0m\t\n",
      "\u001b[0mRepresent: 400/427\u001b[0m\t\n",
      "\u001b[0mRepresent: 427/427\u001b[0m\t\n",
      "Loading embeddings.\n",
      "Training for 99 classes.\n",
      "Saving classifier to './classifier.pkl'\n",
      "CPU times: user 50 ms, sys: 20 ms, total: 70 ms\n",
      "Wall time: 3.38 s\n"
     ]
    }
   ],
   "source": [
    "!~/openface/util/align-dlib.py ./data/mydataset/train_img align outerEyesAndNose ./data/mydataset/aligned_img --size 96 \n",
    "!rm /mnt/data/mydataset/aligned_img/cache.t7 \n",
    "!~/openface/batch-represent/main.lua -outDir /mnt -data /mnt/data/mydataset/aligned_img\n",
    "%time ! ~/openface/demos/classifier.py train ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=== ./data/mydataset/test_img/tock!22.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.08 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock!67.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.04 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock1.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.07 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock10.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.09 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock11.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.08 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock13.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.08 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock14.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.09 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock16.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.09 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock3.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.08 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock4.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.08 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock5.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.08 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tock9.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tock with 0.10 confidence.\n",
      "CPU times: user 50 ms, sys: 40 ms, total: 90 ms\n",
      "Wall time: 4.72 s\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy12.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tracy with 0.10 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy13.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tracy with 0.09 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy14.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tracy with 0.08 confidence.\n",
      "\n",
      "=== ./data/mydataset/test_img/tracy3.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict tracy with 0.09 confidence.\n",
      "CPU times: user 50 ms, sys: 20 ms, total: 70 ms\n",
      "Wall time: 3.05 s\n"
     ]
    }
   ],
   "source": [
    "%time !~/openface/demos/classifier.py infer ./classifier.pkl ./data/mydataset/test_img/tock*\n",
    "%time !~/openface/demos/classifier.py infer ./classifier.pkl ./data/mydataset/test_img/tracy*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "* 12 次 识别 tock 时间 90ms 平均 7.5ms/次  所有12张都识别到tock 置信分  最低0.04 为侧脸67度 最高0.10 光线灰度变化没有明显对得分产生影响\n",
    "* 4次tracy 用时70ms  所有检测结果均正确    置信分 最高 0.09 最低0.08 \n",
    "\n",
    "# 训练的图片\n",
    "## tock\n",
    " <img src=\"./doc/tock20181024164019.png\"  align=center />\n",
    " \n",
    "## tracy\n",
    " <img src=\"./doc/tracy20181024164236.png\" align=center />\n",
    " \n",
    " ## 测试图片 \n",
    " ## tock\n",
    "  <img src=\"./doc/tock_test.png\"  align=center />\n",
    "  \n",
    " ## tracy\n",
    "   <img src=\"./doc/tracy_test.png\"  align=center />"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 对照组 一下是不能识别的个体\n",
    "* 个体 noman1 为没有经过训练的 \n",
    "置信分<0.03"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=== ./data/mydataset/test_img/noman1.jpg ===\n",
      "/root/.local/lib/python2.7/site-packages/sklearn/preprocessing/label.py:166: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
      "  if diff:\n",
      "Predict kieran with 0.03 confidence.\n",
      "CPU times: user 30 ms, sys: 30 ms, total: 60 ms\n",
      "Wall time: 2.71 s\n"
     ]
    }
   ],
   "source": [
    "%time !~/openface/demos/classifier.py infer ./classifier.pkl ./data/mydataset/test_img/noman*\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 结论\n",
    "\n",
    "openface 的人脸分类需要提供 3-9张的基础数据作为分类训练。\n",
    "预测置信分 ：Predict tracy with 0.09 confidence   分数低的原因可能是 与分类数量有关吗？ 分类的总量越大，分数越低吗？"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
